/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ssm.changeunit;

import com.ssm.changeunit.persistance.ChangeLogDAO;
import com.ssm.changeunit.persistance.ChangeLogDTO;
import com.ssm.changeunit.persistance.PersistanceException;

/**
 *
 * @author 시리우스
 */
public class ChangeLogFactory extends AbstractFactory {
    @Override
    public ChangeLog createProduct(String changeLogId) throws CreateException {
        try {
            ChangeLogDAO changeLogDAO = new ChangeLogDAO();
            
            ChangeLogDTO changeLogDTO = changeLogDAO.find(changeLogId);
            
            if(changeLogDTO == null) {
                changeLogDTO = new ChangeLogDTO();
                
                changeLogDTO.setChangeLogId(changeLogId);
                
                changeLogDAO.insert(changeLogDTO);
            }
            
            return new ChangeLog(changeLogId);
        }
        catch(PersistanceException ex) {
            throw new CreateException("ChangeLog를 생성하는데 실패했습니다.", ex);
        }
    }
}